// pages/index.js
import Layout from '../components/Layout'
import Movie, { loadMovie } from '../components/Movie'
import Swiper, { loadSwiper } from '../components/Swiper'

export default function Home({swiper, movie}) {
  console.log(movie)
  return (
    <Layout>
      {/* 接收数据并传回给 Swiper */}
      <Swiper data={swiper} />
      {/* 接收数据并传回给 Movie */}
      <Movie data={movie} title="电影" />
    </Layout>
  )
}

export async function getStaticProps () {
  // 获取轮播图数据
  let { data: swiper } = await loadSwiper()
  // 获取对应列表数据
  let { data: movie } = await loadMovie()
  return {
    props: {
      swiper,
      movie
    }
  }
}